import time

from openpyxl import load_workbook


def aa(lookup_value):
    for x in range(4, ws.max_row + 1):
        if ws.cell(x, 1).value == lookup_value:
            return x


t = time.localtime()
date_today = time.strftime("%Y.%m.%d", t)

path = "//192.168.70.101/19计划管理部/01.计划/1，数据处理工具/file/"
wb_qgmxb = load_workbook(path + date_today + "/source_file_Ⅱ" + "/请购明细表" + date_today + ".xlsx")
ws_qgmxb = wb_qgmxb.active

wb = load_workbook("C:/Users/10352/Desktop/1.xlsx")
ws = wb.active

for i in range(2, ws_qgmxb.max_row + 1):
    print(i)
    for j in range(2, 13):
        if ws.cell(1, j).value <= ws_qgmxb.cell(i, 1).value < ws.cell(2, j).value:
            y = aa(ws_qgmxb.cell(i, 2).value)
            ws.cell(y, j).value += ws_qgmxb.cell(i, 3).value
            continue

wb.save("C:/Users/10352/Desktop/1.xlsx")
